﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace TestInputService
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8000/calculator");
            ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
            ServiceMetadataBehavior smdb = new ServiceMetadataBehavior();
            smdb.HttpGetEnabled = true;
            selfHost.Description.Behaviors.Add(smdb);
            selfHost.Open();

            Console.WriteLine("Serivce is avilable");
            Console.ReadLine();

            selfHost.Close();
          
        }
    }

    [ServiceContract]
    public interface ICalculatorService
    {
        [OperationContract]
        int Add(int x, int y);
    }

    public class CalculatorService : ICalculatorService
    {
        int ICalculatorService.Add(int x, int y)
        {
            int result = x+y;
            Console.WriteLine("Added {0} + {1} which resulted in {2}", x, y, result);
            return result;
        }
    }

}
